var csInterface = new CSInterface();

// 个人主页
var homePageElement = document.querySelector("#homePage");
homePageElement.addEventListener("click", callHomepage);

function callHomepage() {
  window.cep.util.openURLInDefaultBrowser('https://gitee.com/brzjomo');
}

var runButtonDimension = document.querySelector("#btn-dimension");
runButtonDimension.addEventListener("click", dimension);

function dimension() {
  // 获取制图比例
  var drawingScaleElement = document.getElementById("drawing-scale");
  var drawingScale = parseInt(drawingScaleElement.options[drawingScaleElement.selectedIndex].value);

  // 获取数据精度
  var dataAccuracyElement = document.getElementById("data-accuracy");
  var dataAccuracy = parseInt(dataAccuracyElement.options[dataAccuracyElement.selectedIndex].value);

  // 获取字号
  var fontSize = parseFloat(document.getElementsByName("text-input")[0].value);

  // 获取样式序号
  var lineStyle = parseInt(document.getElementsByName("line-style")[0].value);

  // 获取单位文本
  var unitElement = document.getElementById("unit");
  var unit = parseInt(unitElement.options[unitElement.selectedIndex].value);

  // 获取布尔-是否反转负值
  var ifReverseElement = document.getElementById("ifReverse");
  var ifReverse = ifReverseElement.checked;

  // 获取布尔-是否反转文本偏移位置
  var ifReverseOffsetElement = document.getElementById("ifReverseOffset");
  var ifReverseOffset = ifReverseOffsetElement.checked;

  // 获取布尔-是否添加单位
  var ifAddUnitElement = document.getElementById("ifAddUnit");
  var ifAddUnit = ifAddUnitElement.checked;

  csInterface.evalScript('lengthen(' + drawingScale + ', ' + dataAccuracy + ', ' + fontSize + ', ' + lineStyle + ', ' + unit + ', ' + ifReverse + ', ' + ifReverseOffset + ', ' + ifAddUnit +')');
}
